


import {
  get,
  post,
  put,
} from "./base_service"


/**
 * 佳宝首页相关接口
 *
 * allen  2023-12-19
 */

/**
 * 
 *获取我的推广佣金详情
 */
const getMyPromotionCommission = () => {
  return new Promise((resolve, reject) => {
    get("/api/front/commission").then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.message)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}


/**
  * 
  * 推广人数查询
  * 
  */
const queryPromotionPeople = () => {
  return new Promise((resolve, reject) => {
    get("/api/front/spread/people/count").then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.message)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}


/**
  * 
  * 推广人数列表
  * data:{
  *   
  * }
  */
const queryPromotionPeopleList = (data) => {
  return new Promise((resolve, reject) => {
    get("/api/front/spread/people", data).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.message)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}


/**
  * 
  * 获取佣金明细列表
  */
const queryPromotionCommissionList = (page, limit, status, dateLimit) => {
  return new Promise((resolve, reject) => {
    // let params = {
    //   page,
    //   limit,
    //   status,
    //   dateLimit
    // }
    get("/api/front/spread/commission/detail?page=" + page + "&limit=" + limit + "&status=" + status + "&dateLimit=" + dateLimit).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.message)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}

/**
  * 
  * 获取订单明细列表
  */
const queryPromotionOrderList = (page = 1, limit = 10) => {
  return new Promise((resolve, reject) => {
    let params = {
      page,
      limit
    }
    get("/api/front/spread/order", params).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.message)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}
/**
  * 
  * 推广人排行
  */
const queryPromotionPeopleRank = (page = 1, limit = 10, type = 'week') => {
  return new Promise((resolve, reject) => {
    let params = {
      page,
      limit,
      type
    }
    get("/api/front/rank", params).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.message)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}

/**
  * 
  * 推广人佣金排行
  */
const queryPromotionCommissionRank = (page = 1, limit = 10, type = 'week') => {
  return new Promise((resolve, reject) => {
    let params = {
      page,
      limit,
      type
    }
    get("/api/front/brokerage_rank", params).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.message)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}

/**
  * 
  * 推广人佣金排行名次
  */
const queryPromotionCommissionRankNumber = (type = 'week') => {
  return new Promise((resolve, reject) => {
    let params = {
      type
    }
    get("/api/front/user/brokerageRankNumber", params).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.message)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}

module.exports = {
  getMyPromotionCommission,
  queryPromotionPeople,//推广人数查询
  queryPromotionPeopleList,
  queryPromotionCommissionList,//获取佣金明细列表
  queryPromotionOrderList,//获取订单明细列表
  queryPromotionPeopleRank,//获取推广人排行
  queryPromotionCommissionRank,//获取推广人佣金排行
  queryPromotionCommissionRankNumber,//推广人佣金排行名次
}


